home *** CD-ROM | disk | FTP | other *** search
- title 'extended character set for the HGC Plus'
- name csls7
- page 55,132
-
- ;
- ; RAM-Loadable Character Sets for the IBM PC
- ; Listing 7
- ;
- ; Richard Wilton
- ; July 1986
- ;
-
- ; Notes:
- ; This program makes available two different 256-character definition
- ; tables for use on the Hercules Graphics Card Plus. The first table
- ; consists of the ROM BIOS 8 by 8 "double-dot" characters. The
- ; second table is the reverse of the first (i.e., black on white rather
- ; than white on black).
- ;
- ; For Hercules Graphics Card Plus ONLY.
-
-
- cseg segment para public 'CODE'
-
- assume cs:cseg,ds:cseg
-
- org 100h ; initial program counter for .COM file
-
- ; set configuration switch on HGC Plus
- label0: mov dx,3BFh ; i/o port address
- mov al,1 ; activate RAM from B000:0000
- out dx,al ; through B000:7FFF
-
- ; Copy 1st 256 character definitions into character generator RAM from BIOS ROM
- mov ax,0F000h
- mov ds,ax
- mov si,0FA6Eh ; DS:SI -> start of 8x8 character
- ; definition table in ROM
- mov ax,0B000h
- mov es,ax
- mov di,4000h ; ES:DI -> start of Hercules font
- ; definition storage area
-
- xor al,al ; AL := zero byte (used for padding)
- mov cx,256 ; CX := # of characters in table
-
- label1: push cx ; preserve loop counter
-
- mov cx,8 ; CX := # of bytes in one character
- ; definition
- rep movsb ; copy to HGC font storage area
-
- mov cx,8 ; CX := # of bytes of padding
- rep stosb ; store zeroes
-
- pop cx ; loop across all 256 characters
- loop label1
-
- ; Copy 2nd 256 character definitions into character generator RAM
- mov ax,0B000h
- mov ds,ax
- mov si,4000h ; DS:SI -> start of 8x8 character
- ; definition table in HGC Plus RAM
- mov cx,256*16 ; CX := size of 256-character table
-
- label2: lodsb ; copy "reverse" of 1st 256 chars ...
- not al
- stosb ; .. into table for 2nd 256 chars
- loop label2
-
- ; Program the CRT controller to display 25 lines of 8 by 14 characters.
- mov dx,3B4h ; CRT controller register index port
-
- push cs
- pop ds
- mov si,offset regs00_0D ; DS:SI -> start of table of register
- ; values
-
- mov cx,0Eh ; CX := loop counter
- xor ah,ah ; AH := 0 (initial CRT controller
- ; register number)
- label3: mov al,ah
- out dx,al ; store CRT controller index reg
-
- lodsb ; AL := data for CRT controller reg
- inc dx ; DX := 3B5h (CRT data reg port)
- out dx,al ; store data to CRT controller reg
- dec dx ; DX := 3B4h
-
- inc ah ; AH := next CRT controller index #
- loop label3
-
- mov cx,3
- mov ah,14h ; index value for xModeReg
-
- label4: mov al,ah ; Same loop for extra CRT controller ..
- out dx,al ; .. regs used with extended ..
- ; .. character set
- lodsb
- inc dx
- out dx,al
- dec dx
-
- inc ah
- loop label4
-
- ; Update BIOS RAM area in segment 40h
- mov ax,40h
- mov ds,ax
- mov word ptr ds:[4Ah],90 ; CRT_COLS := 90
- mov word ptr ds:[4Ch],1400h ; CRT_LEN := 90 columns * 25 rows
- ; * 2 bytes/char, rounded up to next
- ; higher 1K
- ; Display a message
- push cs
- pop ds
- mov dx,1859h ; use BIOS scroll routine ...
- mov cx,0 ; .. to set attribute bytes in ..
- mov bh,0 ; .. display buffer to zero
- mov ax,600h
- int 10h
-
- mov si,offset csmsg0 ; 1st message
- mov bl,0 ; BL (high nibble) := 0 (normal attrib)
- ; BL (low nibble) := 0 (1st 256 chars)
- mov cx,48 ; length of string
- call show ; display string using char set 0
-
-
- mov si,offset csmsg1 ; 2nd message
- mov bl,81h ; BL (hi nibble) := 8 (intense video)
- ; BL (lo nibble) := 1 (2nd 256 chars)
- mov cx,49
- call show ; display string using char set 1
-
- ; Pause, then disable RAM character generator and restore original state
- mov si,offset KeyMsg
- mov bl,0
- mov cx,33
- call show ; display "Press a key" message
-
- mov ah,1
- int 21h ; wait for a keypress
-
- mov al,14h ; write xModeReg ...
- mov dx,3B4h
- out dx,al ; .. to disable extended character set
- mov al,0
- inc dx
- out dx,al
-
- mov ax,7
- int 10h ; call BIOS, restore default video mode
-
- ; Exit to DOS
- mov ax,4C00h
- int 21h
-
-
-
- ; Subroutine which displays a string using a given attribute
-
- show proc near ; Caller: DS:SI -> string
- ; CX = length of string
- ; BL = attribute
- jcxz show2
-
- show1: lodsb ; AL := next char
- call emit ; display this character
- loop show1
-
- show2: ret
-
- show endp
-
-
- ; Subroutine which displays a single character using a given attribute
- ; Bits 0-3 of the attribute byte and bits 0-7 of the character form an
- ; 12-bit extended character code. Bits 4-7 of the attribute byte determine
- ; the actual attribute displayed.
-
- emit proc near ; Caller: AL = character
- ; BL = attribute
- ; Returns: nothing, but advances
- ; the cursor
- push bx
- push cx
-
- cmp al,20h
- jb emit1 ; jump if control character
-
- push ax ; save char on stack
- mov cx,1 ; CX := # of chars to write
- mov bh,0 ; BH := video display page 0
- mov ah,9 ; call BIOS to write attribute and
- int 10h ; character at cursor
- pop ax ; AL := character
-
- emit1: mov ah,0Eh ; call BIOS to rewrite character in
- int 10h ; "teletype mode" which advances
- ; the cursor
- pop cx
- pop bx
- ret
-
- emit endp
-
-
- ; table of CRT controller register values
-
- regs00_0D db 6Dh,5Ah,5Ch,0Fh ; regs 0 - 3 (8 wide)
- db 19h,06h,19h,19h ; regs 4 - 7 (14 high)
- db 02h,0Dh,0Ch,0Dh ; regs 8 - 0Bh (scans/char,
- ; cursor location)
- db 00h,00h ; regs 0Ch - 0Dh (always zero)
-
- xModeReg db 07h ; "48K RamFont", 8 dot wide
- ; characters
- ScoreReg db 0Dh ; underscore reg
- StrikeReg db 06h ; overstrike reg
-
- ; Strings to be displayed
-
- csmsg0 db 'These characters are in the first group of 256',0Dh,0Ah
- csmsg1 db 'These characters are in the second group of 256',0Dh,0Ah
- KeyMsg db 0Dh,0Ah,'Press any key to continue ...',0Dh,0Ah
-
- cseg ends
-
- end label0